#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>

int main() {
    int n = 0;
    int hour = 0, min = 0, sec = 0;
    scanf("%d", &n);

    int* arr = (int*)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    for (int i = 0; i < n; i++) {
        sec += arr[i];
        min += sec / 60;
        hour += min / 60;
        sec = sec % 60;
        min = min % 60;
        hour = hour % 24;
        printf("%d %d %d\n", hour, min, sec);
    }

    return 0;
}